{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "95eb2666",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "## 1.字典的三种创建模式\n",
    "## 2.字典的性质\n",
    ">1.无序的 \n",
    ">2.key唯一\n",
    ">3.key不可变性\n",
    "# 本周学习内容\n",
    "# 1.字典的循环遍历\n",
    "# 2.字典的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "122d57cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"stu10001\":\"alex\",\n",
    "    \"stu10002\":\"jack\",\n",
    "    \"stu10003\":\"marry\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7b895f9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'alex', 'stu10002': 'jack', 'stu10003': 'marry'}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "25ba144c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu10001\n",
      "stu10002\n",
      "stu10003\n"
     ]
    }
   ],
   "source": [
    "# i 指的是 内容/元素（item）\n",
    "for i in info:\n",
    "    print(i)\n",
    "    # i只是key的值，并没有真正意义上获取到字典的完整信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f1aa53a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu10001 alex\n",
      "stu10002 jack\n",
      "stu10003 marry\n"
     ]
    }
   ],
   "source": [
    "# A-2\n",
    "# 字典的循环 如何循环 key：value 作为items 输出\n",
    "for  k,v in info.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ceaae3a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践1：  学号的k 去掉stu 然后输出新的字典\n",
    "new_info = {}\n",
    "for k,v in info.items():\n",
    "    # 字典的新增\n",
    "    new_info[k[3:]] = v.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "9d17d1ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'10001': 'ALEX', '10002': 'JACK', '10003': 'MARRY'}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "03f7c2f3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
